#pragma once

#include "../ChessCore/IAppReceiver.h"

#include "../ChessCore/IAppSender.h"
#include "../ChessCore/IEngine.h"

#include "WinBoardInputQueue.h"
#include "WinBoardInputThread.h"

namespace Rorn
{
	namespace Chess
	{
		class WinBoardMessage;

		class WinBoardReceiver : public IAppReceiver
		{
		public:
			WinBoardReceiver(IAppSender* appSender, IEngine* theEngine);
			~WinBoardReceiver(void);

			virtual bool IsTimeToQuit();
			virtual void Update();
		private:
			void ProcessMessage(const std::string& messageText);

			void ProcessForceMessage(const WinBoardMessage& message);
			void ProcessGoMessage(const WinBoardMessage& message);
			void ProcessLevelMessage(const WinBoardMessage& message);
			void ProcessNewMessage(const WinBoardMessage& message);
			void ProcessPostMessage(const WinBoardMessage& message);
			void ProcessProtoVerMessage(const WinBoardMessage& message);
			void ProcessQuitMessage(const WinBoardMessage& message);
			void ProcessRandomMessage(const WinBoardMessage& message);
			void ProcessUserMoveMessage(const WinBoardMessage& message);
			void ProcessXBoardMessage(const WinBoardMessage& message);

			WinBoardInputQueue inputQueue_;
			WinBoardInputThread inputThread_;

			IAppSender* appSender_;
			IEngine* theEngine_;

			bool isTimeToQuit_;
		};
	}
}
